<script setup>
import { onMounted, nextTick } from 'vue';
import { useRouter } from 'vue-router';

let router = useRouter();
  const getMessage = () => {
  window.addEventListener('message', e => {
      // 通过origin对消息进行过滤，避免遭到XSS攻击
      if (e.origin === 'http://sassp-web.cras-uat.crc.com.cn' || e.origin === 'https://cras.crc.com.cn') {
        const query = router.currentRoute.value.query;
        if (query.buCode && query.ldap) {
          return;
        } else {
          let monthStr = ''
          if (e.data.month) {
            monthStr = '&month=' + e.data.month;
          }
          window.location.href = router.currentRoute.value.path + '?buCode=' + e.data.buCode + '&ldap=' + e.data.ldap + monthStr;
        }
      }
  }, false);
}
const toErrPage = () => {
  let access = true;
  if (window.self === window.top) {
    access = true;
  }
  // 当页面被iframe嵌入是有权限访问页面
  if (router.currentRoute.value.path !== '/403' && !access) {
    router.push({ name: '403' });
  }
}
onMounted(() => {
  nextTick(() => {
    toErrPage();
  })
  getMessage();
});
</script>

<template>
    <router-view />
</template>

<style lang="less" scoped>
//.main {
  //min-width: 1920px;
  //min-height: 1080px;
  //overflow: auto;
  //@media screen and (width < 1920px) {
  //  .main {
  //    width: 1920px;
  //    height: 1080px;
  //    overflow: auto;
  //  }
  //}
//}
</style>
